Repository navigation
Decode CCITT Group 3 and Group 4 fax images - #23
Merged
Merged
Conversation
PdfFilters.Ccitt decodes the T.4 run-length tables, the two-dimensional modes, Group 3 end-of-line and tag bits, and Group 4 all-2D lines. PdfImageFilters dispatches it and honours /K, /Columns, /Rows, /BlackIs1, /EncodedByteAlign and /EndOfLine, so a scanned bilevel page yields Gray8 pixels instead of ImageFilterUnsupported. The decoder is checked against Group 3 and Group 4 strips Pillow wrote through libtiff (Assets/ccitt), with the bitmap Pillow decodes as the reference. The two-dimensional b1 is measured from the last changing element (a0), which is the difference between a line that completes and one whose vertical mode resolves to the left of the position. The scoped Stryker run over PdfFilters.Ccitt.cs is 78.80% (580 mutants: 394 killed, 48 survived, 58 no coverage); the survivors are the parameter defaults, the malformed-stream error branches and a loop guard, and docs/mutation-testing.md reads them. Three tests were added after the run. ADR-005, parity row 14, the manual chapter 8 and the changelog record the slice; the manual is rebuilt.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The second slice of 4a-volledig (ADR-005):
CCITTFaxDecode.Pdf/PdfFilters.Ccitt.cs— the T.4 white and black run tables, Group 3 one-dimensional and two-dimensional lines (/K= 0 and/K> 0, with the tag bit after each EOL) and Group 4 (/K< 0, all 2D against the line above)./Columns,/Rows,/BlackIs1,/EncodedByteAlignand/EndOfLineare honoured; a bitmap above the budget is measured and not kept; a stream that stops mid-line is refused.PdfImageFiltersdispatches it; a scanned bilevel page now yieldsGray8pixels instead ofImageFilterUnsupported.PdfCcittFilterTests— 8 cases against the committed Pillow/libtiff strips (Assets/ccitt): G4, G3, theBlackIs1complement, geometry from the image, the budget, no row count, a truncated stream, and a non-CCITT stream.The 2D fix
b1is measured from the last changing element (a0) and searched strictly greater thana0, not>= position: after a vertical or horizontal mode the last transition is the new position, so>= positionselects the transition just consumed. On the fixture that made line 12'sV-3resolve to 9; witha0it resolves to 13 and the line completes. ADR-005 records the rule.Evidence
dotnet build -c Release→ 0 warnings, 0 errors;dotnet test→ 1242 passed, 0 failed onnet10.0andnet11.0.PdfFilters.Ccitt.cs→ 78.80% (580 mutants: 394 killed, 48 survived, 58 no coverage).docs/mutation-testing.mdreads the survivors; three tests were added after the run.check: ok); ADR-005, parity row 14, chapter 8 and the changelog record the slice.Next
DCTDecode(JPEG) is the next slice in ADR-005, thenJPXDecodeandJBIG2Decode.